package com.wander.rep.formats;

import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;

/**
 * A simple formatter to convert bar indexes into sensor names.
 */
@SuppressWarnings("serial")
public class DomainFormat extends Format {
    @Override
    public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
        Number num = (Number) obj;

        // using num.intValue() will floor the value, so we add 0.5 to round instead:
        int roundNum = (int) (num.floatValue() + 0.5f);
        switch(roundNum) {
            case 0:
                toAppendTo.append("Bedroom");
                break;
            case 1:
                toAppendTo.append("Kitchen");
                break;
            case 2:
                toAppendTo.append("Garden");
                break;
        }
        return toAppendTo;
    }

    /*
     * (non-Javadoc)
     * @see java.text.Format#parseObject(java.lang.String, java.text.ParsePosition)
     */
	@Override
	public Object parseObject(String string, ParsePosition position) {
		// TODO Auto-generated method stub
		return null;
	}
}